package com.thwj.project.app.api;

import com.thwj.framework.web.domain.R;
import com.thwj.framework.web.service.TokenService;
import com.thwj.project.app.api.vo.AppUserVipVO;
import com.thwj.project.app.service.AppUserVipService;
import com.thwj.project.pay.dto.PayResultDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@Api(tags="app 用户会员模块")
@RestController
@RequestMapping("/app/vip")
public class AppUserVipController {


    @Autowired
    private TokenService tokenService;
    @Autowired
    private AppUserVipService appUserVipService;

    @ApiOperation(value = "获取当前用户的会员状态",notes = "获取当前用户的会员状态")
    @GetMapping("/getUserVipInfo")
    public R<AppUserVipVO> getUserVipInfo() {
        AppUserVipVO appUserVipVO  = appUserVipService.getUserVip(tokenService.getLoginUser());
        return R.data(appUserVipVO);
    }


    @ApiOperation(value = "创建会员订单并返回支付信息",notes = "创建会员订单并返回支付信息")
    @PostMapping("/createVipOrderPay")
    public R<PayResultDTO> createVipOrderPay() {
        PayResultDTO payResultDTO = appUserVipService.createVipOrder(tokenService.getLoginUser());
        return R.data(payResultDTO);
    }

}
